﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;

namespace UVMComm
{
    class md5util
    {
        public static byte[] getMd5HashBytes(string input)
        {

            char[] hasharr = getMd5Hash(input);
            
            List<byte> bytelist = new List<byte>();
            for (int i = 0; i < hasharr.Length; i++)
                bytelist.Add((byte)hasharr[i]);

            return bytelist.ToArray();
        }
        private static char[] getMd5Hash(string input)
        {
            MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
            byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));

            StringBuilder sBuilder = new StringBuilder();
            foreach (byte item in data)
                sBuilder.Append(item.ToString("x2"));

            return sBuilder.ToString().ToCharArray();
        }
    }
}
